(ns controllers.upload
  (:use [compojure.core]
        [ring.middleware.params]
        [ring.middleware.multipart-params]
        [ring.adapter.jetty]
        [hiccup.core]
        [clojure.java.io]
        [controllers.slika]
        [view.stranice])
  (:import [java.io File]))


(defn upload-file [file filter para]
  (let [file-name (file :filename)
        size (file :size)
        actual-file (file :tempfile)]
    (do
     
      (def p (format "./public/images-u/%s" file-name))
       
      (copy actual-file (File. p)
         ;  (prikaz-slike p ) );(str "green-filter")
       )
	      (let [a (prikaz-slike filter p (if-not (= para "") para ))]
	      {:status 200
	       :headers {"Content-Type" "text/html"}
	       :body (view-layout
	                 [:img {:src a :alt file-name :width "500px" :height "500px"}] ; (format "/images-u/%s" file-name)
	                 [:a {:href (str "/slika?putanja=" p)} "Download"])}
	      )
      )
    
    ))

 

